package activity.personal.qianbao;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.hutoubenjg.R;

import java.util.Observable;
import java.util.Observer;

import base.BaseActivity;
import presenter.SysTemPresenter;
import util.utls.ByAlert;
import util.utls.IsUtilUid;
import util.utls.OnPasswordInputFinish;
import util.utls.PasswordView;
import util.volley.ResultEntity;


/**
 * 记得支付密码(修改密码完成)
 *
 */
public class JiDePassTwoActivity extends BaseActivity implements Observer{
    TextView tvTitle;
    ImageView back;

    PasswordView pwdView;// 支付密码
    SysTemPresenter presenter;
    String pwds;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ji_de_pass_two);
        tvTitle.setText(R.string.app_name);
        pwds=getIntent().getStringExtra("paypentPass");
        presenter=new SysTemPresenter(this);
        final PasswordView pwdView = (PasswordView) findViewById(R.id.pwd_view);

        // 添加密码输入完成的响应
        pwdView.setOnFinishInput(new OnPasswordInputFinish() {
            @Override
            public void inputFinish() {
                // 输入完成后跳转
                // 也就是说——>实现你的交易逻辑什么的在这里写
                String newspwd=pwdView.getStrPassword();
                presenter.onChongzhiPwd(IsUtilUid.isUid(),pwds,newspwd);

            }
        });
    }

    @Override
    protected void onInit() {


    }

    @Override
    protected void onReadIntent(Bundle bundle) {

    }

    @Override
    public void onClick(View v) {
        if (v.getId()== R.id.back) {
            finish();
        }
    }

    @Override
    public void update(Observable observable, Object data) {
        ResultEntity entity = handlerError(data);
        if (entity != null) {
            IsUtilUid.tianjia(entity);
            if (entity.getEventType() == presenter.Chongzhimima_success) {
                ByAlert.alert(entity.getData()+"");
                finish();
                Intent intent=new Intent("Chongzhimima");
                sendBroadcast(intent);
            }
        }
        }
}
